const http = require('http');

// let server = http.createServer((req, res) => {
//     res.writeHead(200, {
//         "Content-Type": "text/html;charset=UTF-8"
//     });
//     res.write("写入这一段话");
//     res.end("这是一个人的数据");
// });
let server = http.createServer((req, res) => {
    if (req.url === "/1.html") {
        res.writeHead(200, {
            "Content-Type": "text/html;charset=UTF-8"
        });
        res.end("这是1.html");
        console.log("这是1.html")
    } else if (req.url === "/2.html") {
        res.writeHead(200, {
            "Content-Type": "text/html;charset=UTF-8"
        });
        res.end("这是2.html");
        console.log("这是2.html")
    } else if (req.url === "/") {
        res.writeHead(200, {
            "Content-Type": "text/html;charset=UTF-8"
        });
        res.end("这是根目录");
    } else {
        res.writeHead(404, {
            "Content-Type": "text/html;charset=UTF-8"
        });
        res.end("访问的页面不存在！！！");
    }
});

server.listen(8081);